import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * The ProducerEnemy have the special power to create new Basic Enemy
 * 
 * @author (Arturo Aaron Rios Obregon) 
 * @version (29 june 2013)
 */
public class ProducerEnemy extends Enemy
{
    private SimpleTimer cTimer;
    /**
     * Constructor
     */
    public ProducerEnemy()
    {
        super(150);
        cTimer = new SimpleTimer();
        cTimer.mark();
    }
    
    /**
     * The act method makes move the enemies, check if them touch bullets, create items if them die
     * and eliminate the enemies if his lifes is zero.
     */
    public void act() 
    {
        super.tocaBala();        
        if(getY()<80)
            mueve();
        else
            if(cTimer.millisElapsed()/1000>2)
            {
                creaBasicos();
                cTimer.mark();
            }
        super.creaItem();
        super.vidaCero();
    }    
    
    /**
     * Method to help to create new Basic enemies.
     */
    public void creaBasicos()
    {
        BasicEnemy ene = new BasicEnemy();
        getWorld().addObject(ene,getX(),getY()+75);
    }
    
    /**
     * Redefined method
     * This method move the enemy.
     */
    public void mueve()
    {
        setLocation(getX(),getY()+1);
    }
}
